/**
 * $Id: Genre.java 20 2006-09-16 20:32:08Z willi.w $
 */
package at.wwu.tunes2db.types;

import java.util.Hashtable;

import org.apache.log4j.Logger;


/**
 * @author willi.w
 * Genre information
 */
public class Genre extends Element {
    private static final Logger log = Logger.getLogger(Genre.class.getName());

    private static final Hashtable<String, Genre> genres = new Hashtable<String, Genre>();

    private Genre(String new_name) {
        super(new_name);
    }

    public static Genre add(String name) {
        
        if (genres.containsKey(name.trim())) {
            instance = genres.get(name.trim());
            instance.isNew = false;
        } else {
            instance = new Genre(name.trim());
            instance.isNew = true;
            genres.put(name.trim(), (Genre) instance);
            log.debug("Genre.add("+ (instance.isNew?"new ":"") + name + ")");
        }        
        return (Genre) instance;
    }

    @Override
    public String toString() {
        return "Genre " + id + ": " + name;
    }
}
